import React from "react";
import {Switch, Route, withRouter} from 'react-router-dom'
import Login from "./Login/Login";
import './app.less'
import {message} from "antd";
import Home from "./Home/Home";

function App(props) {
    React.useEffect(() => {
        const path = props.location.pathname;
        const isLogin = JSON.parse(window.sessionStorage.getItem('status'));
        if (isLogin !== true && path !== '/login') {
            window.location.href = '/login'
        }
    }, [])

    return (
        <>
            <Switch>
                <Route path={'/'} exact component={Home}/>
                <Route path={'/home'} component={Home}/>
                <Route path={'/login'} component={Login}/>
            </Switch>
        </>
    )
}

export default withRouter(App)